From a066e5136692a909b62f29158c4a4b0f007e2b22 Mon Sep 17 00:00:00 2001
From: wb9688 <wb9688@users.noreply.github.com>
Date: Mon, 1 Mar 2021 16:40:34 +0100
Subject: [PATCH] Only do X11-specific stuff on X11

---
 src/lxappearance.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/src/lxappearance.c b/src/lxappearance.c
index f31e794..4bd438a 100644
--- a/src/lxappearance.c
+++ b/src/lxappearance.c
@@ -117,16 +117,20 @@ static gboolean check_lxde_dbus()
 
 static void check_lxsession()
 {
-    lxsession_atom = XInternAtom( GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), "_LXSESSION", True );
-    if( lxsession_atom != None )
+    GdkDisplay *display = gdk_display_get_default();
+    if (GDK_IS_X11_DISPLAY(display))
     {
-        XGrabServer( GDK_DISPLAY_XDISPLAY(gdk_display_get_default()) );
-        if( XGetSelectionOwner( GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), lxsession_atom ) )
+        lxsession_atom = XInternAtom( GDK_DISPLAY_XDISPLAY(display), "_LXSESSION", True );
+        if( lxsession_atom != None )
         {
-            app.use_lxsession = TRUE;
-            lxsession_name = g_getenv("DESKTOP_SESSION");
+            XGrabServer( GDK_DISPLAY_XDISPLAY(display) );
+            if( XGetSelectionOwner( GDK_DISPLAY_XDISPLAY(display), lxsession_atom ) )
+            {
+                app.use_lxsession = TRUE;
+                lxsession_name = g_getenv("DESKTOP_SESSION");
+            }
+            XUngrabServer( GDK_DISPLAY_XDISPLAY(display) );
         }
-        XUngrabServer( GDK_DISPLAY_XDISPLAY(gdk_display_get_default()) );
     }
 
     /* Check Lxsession also with dbus */
